package com.shiyingzi.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.shiyingzi.interceptor.SecurityInterceptor;

/**
 * @author yubin
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {


	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/*")
			.excludePathPatterns("/login", "/doLogin")
			.excludePathPatterns("/User/query")
			.excludePathPatterns("/Menu/query")
			.excludePathPatterns("/Dictionary/query","/Dictionary/doAddDic","/Dictionary/doUpdateDic","/Dictionary/doDeleteDic")
		    .excludePathPatterns("/Role/query")
		    .excludePathPatterns("/product/query","/product/insert","/product/updateStateById")
		    .excludePathPatterns("/a_login", "/a_register", "/auser/doALogin", "/auser/ainesrt", "/auser/query"
		    		, "/auser/update", "/auser/upPasswordById")
		    .excludePathPatterns("/a_channel", "/a_channel_edit", "/achannel/ainesrt", "/achannel/query", "/achannel/update"
		    		, "/achannel/findlist").excludePathPatterns("/gw_index","/gw_example","/gw_news","/newsInfo","/gw_product_page","/gw_news_page","/gw_product_sum","/productInfo");
	}

	
//	@Override
//    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
//        Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
//        builder.serializationInclusion(JsonInclude.Include.NON_NULL);
//        ObjectMapper objectMapper = builder.build();
//        SimpleModule simpleModule = new SimpleModule();
//        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
//        objectMapper.registerModule(simpleModule);
//        objectMapper.configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true);// 忽略 transient 修饰的属性
//        converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
//        super.configureMessageConverters(converters);
//    }
}
